Repository navigation
Navigation: Use areInnerBlocksControlled to detect controlled inner blocks - #87096
Conversation
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
Updated as activity occurs, without notifying anyone named here. Add the 📦 Bundle sizeSize Change: -19 B (0%) Total Size: 8.68 MB 📦 View Changed
⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
🏁 Flaky testsSome tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information. should select synced pattern in
|
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the Navigation inner-block control detection update.
No open issues 🎉
What changed in this PR
Updates the Navigation block to detect controlled inner blocks through areInnerBlocksControlled, addressing #46265 without relying on differences between getBlock() and getBlocks().
Changes:
- Reads inner blocks once and classifies them using the controlled-state selector.
- Converts the hook to TypeScript while retaining its return structure.
- Adds unit tests for empty, uncontrolled, and controlled inner blocks.
| File | Description |
|---|---|
packages/block-library/src/navigation/edit/use-inner-blocks.ts |
Adds the typed hook using explicit controlled-state detection. |
packages/block-library/src/navigation/edit/use-inner-blocks.js |
Removes the JavaScript implementation replaced by TypeScript. |
packages/block-library/src/navigation/edit/test/use-inner-blocks.jsdom.test.tsx |
Tests empty and uncontrolled blocks and the transition to controlled blocks. |
Review effort: Balanced
…ies and selection Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
getdave
left a comment
There was a problem hiding this comment.
I don't see any regressions here.
I pushed some additional code coverage recommended after review.
Thanks for maintaining this 👍
Mamaduka
left a comment
There was a problem hiding this comment.
Left two notes, not a blocker here, but can be nice cleanup for follow-up.
What?
Fixes #46265
The Navigation block's
useInnerBlockshook now uses theareInnerBlocksControlledselector to tell whether its inner blocks are controlled.Why?
The hook relied on a quirk:
getBlock()leaves out a controller's inner blocks, whilegetBlocks()includes them. ThegetBlockdocs now warn against relying on that and point toareInnerBlocksControlled.How?
getBlocks( clientId )and split them into controlled and uncontrolled withareInnerBlocksControlled( clientId ). The hook returns the same values as before, soedit/index.jsxis unchanged.Testing Instructions
ref, for example:<!-- wp:navigation --><!-- wp:navigation-link {"label":"Home","url":"/"} /--><!-- /wp:navigation -->Unit tests:
npm run test:unit -- packages/block-library/src/navigatocks.jsdom.test.tsx🤖 Generated with help from Claude Code, reviewed by me.